class GameTimer {
  constructor() {
    this.timers = [];

    this.timers.push(
      new Timer(
        restaurant.config.dayTime,
        Infinity,
        () => window.game.pause,
        () => {
          restaurant.state.today += 1;
          restaurant.cooks.forEach((d) => {
            if (d.onServe) ++d.workTime;
          });
          if (restaurant.state.today % 7 === 0) {
            let sallarys = 0;
            restaurant.cooks.forEach((d) => {
              sallarys +=
                (d.onServe * (d.workTime * restaurant.config.severancePay)) / 7;
            });
            restaurant.state.money -= sallarys;
            new AlertBox(`支付上周薪水${sallarys}元 (。_。)`, 2000, 'error');
          }
        },
        () => {},
      ),
    );
    this.timers.push(
      new Timer(
        100,
        Infinity,
        () => window.game.pause,
        () => {
          if (Math.random() < 100 / restaurant.config.customerInterval) {
            restaurant.addCustom();
          }
        },
        () => {},
      ),
    );
  }

  startAll() {
    this.timers.forEach((d) => {
      d.start();
    });
  }

  stopAll() {
    window.game.pause = true;
  }
}
